package com.zmx.doctor.adapter.base;

import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.zmx.doctor.R;
import com.zmx.doctor.listener.OnItemPictureClickListener;
import com.zmx.doctor.pojo.FriendsMessage;
import com.zmx.doctor.view.activity.FriendsDetailsActivity;
import com.zmx.doctor.view.util.NineGridTestLayout;

import de.hdodenhof.circleimageview.CircleImageView;


/**
 * Description 微信朋友圈九宫格图片Holder
 * Created by Administrator
 * Time 2018/1/3  21:49
 */

public class MomentHolder extends BaseHolder<FriendsMessage> {

    private View view;
    private ImageView live;
    private CircleImageView head;
    private TextView name,like_tv,time,comment_tv;
    private TextView contexts;
    private NineGridTestLayout nineGridTestLayout;
    private OnItemPictureClickListener listener;
    private Context context;

    public MomentHolder(Context context,View view, OnItemPictureClickListener listener) {
        super(view);
        this.listener = listener;
        this.context = context;
    }

    @Override
    public void initView(View view) {
        this.view = view;
        head = view.findViewById(R.id.head);
        live = view.findViewById(R.id.live);
        name = view.findViewById(R.id.name);
        time = view.findViewById(R.id.time);
        comment_tv = view.findViewById(R.id.comment_tv);
        like_tv = view.findViewById(R.id.like_tv);
        contexts = view.findViewById(R.id.context);
        nineGridTestLayout = view.findViewById(R.id.nineTestlayout);

    }

    @Override
    public void bindViewHolder(FriendsMessage girl, int position) {

        Log.e("数据大小","数据大小"+girl.getPicture().size());

        name.setText(girl.getName());
        like_tv.setText(girl.getGives().size()+"");
        time.setText(girl.getPubtime());
        comment_tv.setText(girl.getReplay()+"");
        contexts.setText(girl.getContent());
        nineGridTestLayout.setListener(listener);
        nineGridTestLayout.setItemPosition(position);
        nineGridTestLayout.setSpacing(15);
        nineGridTestLayout.setUrlList(girl.getPicture());
        Glide.with(context).load(girl.getAvatar()).into(head);

        if (girl.getIs_give() == 1){
            live.setImageResource(R.mipmap.waterflow_icon_like_normal_a);
        }else {
            live.setImageResource(R.mipmap.waterflow_icon_like_normal);
        }

        view.setOnClickListener(v -> {

            Intent intent = new Intent();
            intent.putExtra("article_id",girl.getId()+"");
            intent.setClass(context, FriendsDetailsActivity.class);
            context.startActivity(intent);

        });
    }


}
